<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>

<html lang="en">

<head>

    <meta charset="utf-8">

    <title>开盘红股票交易系统-卖出委托</title>

    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">

    <link rel="stylesheet" href="css/bootstrap.css">

    <link rel="stylesheet" href="css/font-awesome.min.css">

    <link rel="stylesheet" href="css/style.css">

    <link rel="stylesheet" href="css/plugin.css">

    <link rel="stylesheet" href="css/landing.css">

    <!--[if lt IE 9]>

    <script src="js/ie/respond.min.js"></script>

    <script src="js/ie/html5.js"></script>

    <![endif]-->

    <script src="js/jquery.min.js"></script>

    <!-- Bootstrap -->

    <script src="js/bootstrap.js"></script>

    <!-- app -->

    <script src="js/app.js"></script>

    <script src="js/app.plugin.js"></script>

    <script src="js/app.data.js"></script>
    <!-- / footer -->

    <script src="js/jquery.min.js"></script>

    <!-- Bootstrap -->

    <script src="js/bootstrap.js"></script>

    <!-- app -->

    <script src="js/app.js"></script>

    <script src="js/app.plugin.js"></script>

    <script src="js/app.data.js"></script>

    <!-- Sparkline Chart -->

    <script src="js/charts/sparkline/jquery.sparkline.min.js"></script>

    <script src="js/ie/excanvas.js"></script>

    <!-- Easy Pie Chart -->

    <script src="js/charts/easypiechart/jquery.easy-pie-chart.js"></script>

    <!--Datatables-->
    <script src="js/datatables/jquery.dataTables.js"></script>
    <link rel="stylesheet" type="text/css" href="css/datatables/jquery.dataTables.css">
    <script type="text/javascript" src="js/datatables/dataTables.bootstrap4.js"></script>

    <!--SweetAlert-->
    <script src="js/sweetalert/sweet-alert.js"></script>
    <link rel="stylesheet" type="text/css" href="js/sweetalert/sweet-alert.css">
    <script type="text/javascript">
        $(document).ready(function() {
            $("#mdata").DataTable({
                language:{
                    url:"zh_CN.json"
                },
                ajax: {
                    url:"http://localhost:6060/StockTrade_war/API/Stock",
                    dataSrc:'data'
                },
                columns:[
                    {data:"stockCode"},
                    {data:"stockName"},
                    {data:"latestPrice"},
                    {data:"aoiaaod"},
                    {data:"iad"},
                    {data:"tradingVolume"},
                    {data:"businessVolume"},
                    {data:"amplitude"},
                    {data:"highestPrice"},
                    {data:"lowestPrice"},
                    {data:"todayOpen"},
                    {data:"yesterdayClose"},
                    {data:"volumeRatio"},
                    {data:"peratioDymatic"},
                    {data:"pbratio"},
                    {data:"marketCap"},
                    {data:"circulationMarketValue"},
                    {data:"risingSpeed"}
                ],
                bAutoWidth:true
            });

            $("#Buybtn").click(function (){
                if($("#inputStockCode").val()=="")
                {
                    swal({
                        title:"注意",
                        text:"购买股票代码不得为空",
                        timer:"1000"
                    })
                    return;
                }
                else if($("#inputBuyCount").val()=="")
                {
                    swal({
                        title:"注意",
                        text:"购入数不得为空",
                        timer:"1000"
                    })
                    return;
                }
                else if($("#inputHighestBuy").val()=="")
                {
                    swal({
                        title:"注意",
                        text:"最高价不得为空",
                        timer:"1000"
                    })
                    return;
                }
                else{
                    let postdata={
                        "StockCode": $("#inputStockCode").val(),
                        "BuyCount": $("#inputBuyCount").val(),
                        "MaxPrice": $("#inputHighestBuy").val()};
                    $.ajax({
                        url: 'http://localhost:6060/StockTrade_war/API/Deal/AddBuy',
                        type: 'post',
                        contentType:"application/json;charset=utf-8",
                        data: JSON.stringify(postdata),
                        async: false, //是否异步提交,默认为true
                        dataType: 'json', //提交的数据格式为JSON,返回的数据格式也是json
                        success: function(resp) {
                                swal({
                                    title:"注意",
                                    text:resp.errorCode,
                                    timer:"2000"
                                })
                        },
                        error: function(resp) {
                            swal({
                                title:"错误",
                                text:"请联系管理员处理",
                                timer:"1000"
                            })
                        }
                    })
                }
            })
            $("#Sellbtn").click(function (){
                if($("#inputSellStockCode").val()=="")
                {
                    swal({
                        title:"注意",
                        text:"出售股票代码不得为空",
                        timer:"1000"
                    })
                    return;
                }
                else if($("#inputSellCount").val()=="")
                {
                    swal({
                        title:"注意",
                        text:"购入数不得为空",
                        timer:"1000"
                    })
                    return;
                }
                else if($("#inputLowestSell").val()=="")
                {
                    swal({
                        title:"注意",
                        text:"最低价不得为空",
                        timer:"1000"
                    })
                    return;
                }
                else{
                    let postdata={
                        "StockCode": $("#InputSellStockCode").val(),
                        "SellCount": $("#InputSellCount").val(),
                        "LowestPrice": $("#InputLowestSell").val()};
                    $.ajax({
                        url: 'http://localhost:6060/StockTrade_war/API/Deal/AddSell',
                        type: 'post',
                        contentType:"application/json;charset=utf-8",
                        data: JSON.stringify(postdata),
                        async: false, //是否异步提交,默认为true
                        dataType: 'json', //提交的数据格式为JSON,返回的数据格式也是json
                        success: function(resp) {
                            swal({
                                title:"注意",
                                text:resp.errorCode,
                                timer:"2000"
                            })
                        },
                        error: function(resp) {
                            swal({
                                title:"错误",
                                text:"请联系管理员处理",
                                timer:"1000"
                            })
                        }
                    })
                }
            })
        })
    </script>
</head>

<body>

<!-- header -->

<header id="header" class="navbar">

    <ul class="nav navbar-nav navbar-avatar pull-right">

        <li class="dropdown">

            <a href="#" class="dropdown-toggle" data-toggle="dropdown">

                <span class="hidden-sm-only" id="Username">Mika Sokeil</span>

                <b class="caret hidden-sm-only"></b>

            </a>

            <ul class="dropdown-menu">

                <li><a href="#">设置</a></li>

                <li><a href="#">个人信息</a></li>


                <li class="divider"></li>

                <li><a href="index.jsp">Logout</a></li>

            </ul>

        </li>

    </ul>

    <a class="navbar-brand" href="#">开盘红股票交易系统</a>


</header>
<!-- / header -->

<!-- nav -->
<nav id="nav" class="nav-primary visible-lg nav-vertical">

    <ul class="nav" data-spy="affix" data-offset-top="50">

        <li><a href="main.jsp"><i class="icon-dashboard icon-xlarge"></i>首页</a></li>

        <li class="dropdown-submenu active">

            <a href="#"><i class="icon-th icon-xlarge"></i>股票交易</a>

            <ul class="dropdown-menu">

                <li class="active"><a href="stocktrade.jsp">股票交易</a></li>
                <li><a href="trade.jsp">交易记录</a></li>

            </ul>

        </li>

        <li class="dropdown-submenu">

            <a href="#"><i class="icon-list icon-xlarge"></i>开户</a>

            <ul class="dropdown-menu">

                <li><a href="open.jsp">提交开户信息</a></li>

                <li><a href="openresult.jsp">查询开户结果</a></li>

            </ul>

        </li>

        <li class="dropdown-submenu">

            <a href="#"><i class="icon-link icon-xlarge"></i>其他操作</a>

            <ul class="dropdown-menu">

                <li><a href="changepw.jsp">修改密码</a></li>

                <li><a href="index.jsp">退出登陆</a></li>

            </ul>

        </li>

    </ul>

</nav>

<!-- / nav -->

<section id="content">

    <section class="main padder">

        <div class="clearfix">

            <h4>整体股票市场</h4>

        </div>
        <div class="row">
            <div class="col-6">
                <section class="panel">

                    <div class="form-horizontal" data-validate="parsley" onsubmit="return false">


                        <div class="form-group">

                            <label class="col-lg-3 control-label">股票代码</label>

                            <div class="col-lg-8">

                                <input type="text" id="inputStockCode" placeholder="股票代码" class="form-control"  required>

                            </div>

                        </div>

                        <div class="form-group">

                            <label class="col-lg-3 control-label">购入数</label>

                            <div class="col-lg-8">

                                <input type="text" id="inputBuyCount" placeholder="购入数" class="form-control" required>

                            </div>

                        </div>

                        <div class="form-group">

                            <label class="col-lg-3 control-label">最高价</label>

                            <div class="col-lg-8">

                                <input type="text" id="inputHighestBuy" placeholder="最高价" data-required="true" class="form-control" required>

                            </div>

                        </div>

                        <div class="form-group">

                            <div class="col-lg-9 col-offset-3">

                                <button class="btn btn-large" id="Buybtn">确定</button>

                            </div>

                        </div>

                    </div>

                </section>
            </div>
            <div class="col-6">
                <section class="panel">

                    <div class="form-horizontal" data-validate="parsley" onsubmit="return false">


                        <div class="form-group">

                            <label class="col-lg-3 control-label">股票代码</label>

                            <div class="col-lg-8">

                                <input type="text" id="InputSellStockCode" placeholder="股票代码" class="form-control"  required>

                            </div>

                        </div>

                        <div class="form-group">

                            <label class="col-lg-3 control-label">卖出数</label>

                            <div class="col-lg-8">

                                <input type="text" id="InputSellCount" placeholder="卖出数" class="form-control" required>

                            </div>

                        </div>

                        <div class="form-group">

                            <label class="col-lg-3 control-label">最低价</label>

                            <div class="col-lg-8">

                                <input type="text" id="InputLowestSell" placeholder="最低价" data-required="true" class="form-control" required>

                            </div>

                        </div>

                        <div class="form-group">

                            <div class="col-lg-9 col-offset-3">

                                <button class="btn btn-large" id="Sellbtn">确定</button>

                            </div>

                        </div>

                    </div>

                </section>
            </div>
        </div>
        <div class="row">
            <section class="panel">

                <div class="pull-out">

                    <table class="table table-striped m-b-none" id="mdata">

                        <thead>

                        <tr>

                            <th>股票代码</th>

                            <th>股票名称</th>

                            <th>最新价格</th>

                            <th>涨跌幅</th>

                            <th>涨跌额</th>

                            <th>成交量</th>

                            <th>成交额</th>

                            <th>振幅</th>

                            <th>最高价</th>

                            <th>最低价</th>

                            <th>今开</th>

                            <th>昨收</th>

                            <th>量比</th>

                            <th>动态市盈率</th>

                            <th>市净率</th>

                            <th>总市值</th>

                            <th>流通市值</th>

                            <th>涨速</th>
                        </tr>

                        </thead>

                        <tbody>

                        </tbody>

                    </table>

                </div>

            </section>
        </div>

    </section>

</section>

<!-- .modal -->



</body>

</html>